//
//  AudioRecordAnimateView.m
//  BaiTengIM
//
//  Created by btcx on 2019/7/31.
//  Copyright © 2019 awh. All rights reserved.
//

#import "AudioRecordAnimateView.h"

@interface AudioRecordAnimateView ()

@property (nonatomic, strong) UIImageView *animateView;
@property (nonatomic, strong) UILabel *tipsLabel;



@end

@implementation AudioRecordAnimateView

- (void)show {
    [[UIApplication sharedApplication].keyWindow addSubview:self];
}

- (void)dismiss {
    [self removeFromSuperview];
}

- (instancetype)initWithFrame:(CGRect)frame {
    CGFloat wh = 140;
    CGFloat y = SCREEN_HEIGHT - wh - 173;
    CGRect frame2 = CGRectMake((SCREEN_WIDTH - wh) / 2, y, wh, wh);
    if (self = [super initWithFrame:frame2]) {
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews {
    self.backgroundColor = [KHEXCOLOR(kMainColor) colorWithAlphaComponent:0.7];
    _animateView = [UIImageView new];
    _animateView.image = [UIImage imageNamed:@"语音弹窗-语音中"];
    _animateView.contentMode = UIViewContentModeCenter;
    
    _tipsLabel = [UILabel new];
    _tipsLabel.textColor = [UIColor whiteColor];
    _tipsLabel.font = [UIFont systemFontOfSize:14];
    _tipsLabel.textAlignment = 1;
    
    [self addSubview:_animateView];
//    [self addSubview:_tipsLabel];
    
    [_animateView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@107);
        make.height.equalTo(@57);
        make.top.equalTo(self).offset(25);
        make.centerX.equalTo(self);
    }];
    
//    [_tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.animateView.mas_bottom).offset(20);
//        make.left.right.equalTo(self);
//        make.height.equalTo(@14);
//    }];
}

- (void)setTips:(NSString *)tips {
    _tips = [tips copy];
    self.tipsLabel.text = tips;
}

@end
